﻿@using CoreData
@model IEnumerable<ProductAttribute>
@if (Model!=null&&Model.Count() > 0)
{
    int i = 0;
    <table cellpadding="0" cellspacing="0" width="100%" class="table" id="tSortableProductAttribute">
        <thead>
            <tr>
                <th width="20px">STT
                </th>
                <th>Tên thuộc tính</th>
                 <th>Giá trị</th>
               
                <th width="60px">Trạng thái
                </th>
                <th width="60px">Chức năng
                </th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {
                i++;
                <tr>
                    <td>
                        @i
                    </td>
                    <td>
                        <span class="SpanId" style="display: none;">@item.ID</span>
                        <span class="SpanName" style="display: none;">@item.AttributeNameExt</span>
                        @item.AttributeNameExt
                    </td>
                    <td>
                      @if (item.AttributeNameExt == "Hình ảnh")
                      {
                           <img src="@Url.Content("~/Media/ProductAttribute/" + item.Value)" width="70px" height="70px" alt="@item.AttributeNameExt" />
                  
                      }
                      else
                      {
                          @item.Value 
                      }

                    </td>
                   
                   
                    <td>
                       @if (item.Active == true)
                       {
                           @:Active
                       }
                       else
                       {
                           @:Not Active 
                       }
                      @*  @Html.CheckBoxFor(x => item.Active, new { @disabled = "disabled" })*@
                    </td>
                    <td>
                    @if (Helper.SessionManagement.Value("pvalue").Contains("U") || Helper.SessionManagement.Value("pvalue").Contains("C"))
                    {
                        <a title="Sửa" href="#" _attributeid="@item.AttributeID" _id="@item.ID" _attributename="@item.AttributeNameExt" _value="@item.Value" _active="@item.Active" class="icon-pencil showedit"></a>
                    }
                    @if (Helper.SessionManagement.Value("pvalue").Contains("D"))
                    {
                        <a title="Xóa" href="#" _id="@item.ID" class="icon-trash delete" onclick="return confirm('Có chắc bạn muốn xóa ?');"></a>
                    }
                    </td>
                </tr>
            }
        </tbody>
    </table>
}
else
{
    <h2 class="error-text">Không tìm thấy dữ liệu.
    </h2>
}